package com.ntd.util;

import com.ntd.frame.awt.component.NtdButton;
import com.ntd.frame.awt.component.NtdJFrame;
import ntd.util.UtilThreadPool;

import javax.swing.*;
import java.util.concurrent.TimeUnit;

public class PrintScreen extends NtdJFrame {

    PrintScreen() {
        super("Java屏幕截图小工具", 400, 300);

        JButton jButton = new NtdButton("点击截图");

        getContentPane().add(jButton);

        UtilThreadPool.scheduledThreadPool.scheduleAtFixedRate(() -> {
            this.setBackImg(UtilSys.getScreenCapture());
        }, 3L, 50L, TimeUnit.MILLISECONDS);

        //为按钮添加监听事件
        jButton.addActionListener(e -> {
            this.setBackImg(UtilSys.getScreenCapture());
        });
    }

    public static void main(String[] args) {
        PrintScreen printScreen = new PrintScreen();
    }
}
